package cn.thoughtworks.school.usercenter.feign;

import cn.thoughtworks.school.usercenter.entities.UserOrganization;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;


@FeignClient(name = "${feign.organizationCenter.name}",
  url = "${feign.organizationCenter.url}")
@Service
public interface OrganizationCenterFeign {

  @PostMapping("api/organizations/{organizationId}/users")
  void addUsersToOrganization(@PathVariable("organizationId") Long organizationId, @RequestBody List<Long> userIds);

  @GetMapping("api/userOrganizations/{organizationId}")
  List<UserOrganization> findUserOrganizationsByOrganizationId(@PathVariable("organizationId") Long organizationId);

  @GetMapping("api/organizations/users/{userId}")
  List<Map> getOrganizationsById(@PathVariable("userId") Long userId);
}
